<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // ES6对象的简写
    // (1) 如果对象的键名和键值对应的变量名相同,可以简写
    // (2) 函数也可以进行简写  => 省略:function

    var name = "张三";
    var age = 18;
    var sex = "男";
    var height = "180cm";
    var weight = "90kg";
    function say(){
        console.log(this.name,this.age);
    }
    
    var zhang = {
        name:name,   // 键名:键值对应的变量名
        age:age,
        sex:sex,
        height:height,
        weight:weight,
        say:say,
        sayHello:function(){
            console.log("hello");
        }
    }
    console.log(zhang);
    
    
    //  ES6对象的简写:
    var zhang = {
        name,   // 键名:键值对应的变量名
        age,
        sex,
        height,
        weight,
        say,
        sayHello(){
            console.log("hello");
        }
    }
    console.log(zhang);
</script>
</html>